<template>
	<view class="newsdetail">
		<view class="title">{{detail.title}}</view>
		<view class="time">
			<text>发布时间：{{detail.add_time | formatDate}}</text>
			<text>浏览量：{{detail.click}}</text>
		</view>
		<view class="content">
			<rich-text :nodes="detail.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				detail: {}
			}

		},
		onLoad(op) {
			this.id = op.id
			this.getNewsDetail(this.id)
		},
		methods: {
			async getNewsDetail(id) {
				const res = await this.$myRequest({
					url: '/api/getnew/' + id
				})
				this.detail = res.data.message[0]
				console.log(this.detail);
			}
		}
	}
</script>

<style lang="scss">
	.newsdetail {
		.title {
			font-size: 32rpx;
			margin: 20rpx 0;
			text-align: center;
		}

		.time {
			font-size: 26rpx;
			width: 750rpx;
			text-align: center;
			display: flex;
			justify-content: space-around;
			margin-bottom: 20rpx;
		}

		.content {
			padding: 0 10px;
		}
	}
</style>
